package com.example.source.spring.bean;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class BeanConfig {

    @Bean(initMethod = "initMethod")
    MethodBean methodBean() {
        return new MethodBean();
    }

    static class MethodBean implements InitializingBean {
        @Override
        public void afterPropertiesSet() throws Exception {
            System.out.println(this + "afterPropertiesSet");
        }

        @PostConstruct
        public void PostConstruct() {
            System.out.println(this + "PostConstruct");
        }

        public void initMethod() {
            System.out.println(this + "initMethod");
        }
    }
}
